#ifndef SSAO_SAMPLE_H
#define SSAO_SAMPLE_H
#include "SampleBase.h"
#include "glslprogram.h"
#include "plane.h"
#include "Quad.h"
#include "objmesh.h"
#include <glm\glm.hpp>
#include "random.h"
namespace ShaderLab {
	class SSAOSample : public SampleBase {
	public:
		SSAOSample();
		~SSAOSample();

		void Init();
		void Update(float time);
		void Render();
		void Imgui();
		void ShutDown();
	private:
		GLSLProgram prog;
		GLuint aoTex[2], woodTex, brickTex;
		GLuint deferredFBO, ssaoFBO, blurFBO;
		GLuint posTex, normTex, colorTex;
		std::unique_ptr<Plane> plane;
		std::unique_ptr<ObjMesh> bunny;
		std::unique_ptr<Quad> screenQuad;

		glm::mat4 sceneProj,model,view,projection;
		Random rand;
		glm::vec3 meshPos;
		float meshScale;
	private:
		GLuint buildRandRotationTex();
		void UpdateMatrices();
		void CreateShader();
		void FBO();
		void GBuffer(GLenum, GLenum, GLuint &);
		void BuildKernel();
		void Pass1();
		void Pass2();
		void Pass3();
		void Pass4();

		void drawScreenFillingQuad();

		void DrawScene();
	};
}
#endif // !TEMPLATE_SAMPLE_H

